<?php
include  $_SERVER['DOCUMENT_ROOT'] . "/modules/config/index.php";
session_start();
$username = $_SESSION["username"];

$server = "http://" . $_SERVER['SERVER_NAME'];
$article= str_replace("modules/articles/content", "", $_REQUEST["article"]);
$article= str_replace(" ", "", $article);
$article_name=basename($article);

$from = $config["admin"][$username]["email"];

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: {$from} \r\n";
$headers .= "BCC: {$from} \r\n";


//Generate to list from the config file;
$to = "";
foreach ($config["admin"] as $key => $admin) {
				if ($to != "") $to .= ",";
				if ($key != $username) $to .= $admin["email"];
}

$name = $config["admin"][$username]["firstname"] . " " . $config["admin"][$username]["surname"];


$message=<<<STOP
<html>
<head>
<title>Article Review Request</title>
</head>
<body>
<img src="{$server}/images/prc_logo.png" alt="Peterborough Regional College">
<h2>Article Review Request</h2>
<p>Please review <a href="{$server}/{$article}">$article_name</a></p>
<p>Regards</p>
<p>{$name}</p>
</body>
</html>
STOP;
$subject="Article Review";

mail($to, $subject, $message, $headers);
$response = "Request email send to {$to}\r\n";
$response .= "A copy of the request has been emailed to you for your records";
echo $response; 
?>